package com.hyy.common.config;

import com.hyy.common.utils.Mail;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

@Configuration
public class MailConfig {

    @Bean
    @ConditionalOnProperty(prefix="spring.mail",name="username")//有spring.mail中的username才会拆功能键bean
    public Mail mail(JavaMailSender mailSender, MailProperties mailProperties) {
        return new Mail(mailSender, mailProperties);
    }
}
